﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;

using Castle.DynamicProxy;

using ProjectBase.Core;

namespace $safeprojectname$.IoC
{
    public static class AopFilterManager
    {
        #region Init

        public static void Init()
        {
            Interceptors.Add(() => new Aop.FilterRestrictionManager());
            Interceptors.Add(() => new Aop.AuditableFilter());
            Interceptors.Add(() => new Aop.TraceableFilter());
            Interceptors.Add(() => new Aop.RestrictMetaDataFilter());
            //Interceptors.Add(() => new FacadeExceptionFilter());
            //Interceptors.Add(() => new FacadeDebugExceptionFilter());
            //Interceptors.Add(() => new DaoExceptionFilter());
            Interceptors.Add(() => new TracingFilter());
        }

        #endregion Init

        public static IEnumerable<IInterceptor> GetFilters()
        {
            var result = Interceptors
                .Select(filter => filter.Invoke());
            return result.ToArray();
        }

        #region properties

        private static readonly ProxyGenerationOptions _aopOptions = new ProxyGenerationOptions { Selector = new AopSelector() };

        public static ProxyGenerationOptions AopOptions { get { return _aopOptions; } }

        public static readonly IList<Func<IInterceptor>> Interceptors = new List<Func<IInterceptor>>();

        #endregion properties
    }
}